﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ESOL.Business.Mst;
using ESOL.Common.Entity;

namespace ESOL.WinUI.Hr
{
    public partial class frmMaintainDepartmentQuery : BaseForm.frmBaseDialogyQueryForm
    {
        public MstDepartmentEntity SelectedDepartment { get; set; }
        public frmMaintainDepartmentQuery()
        {
            InitializeComponent();
        }

        private void BindTreeDepartment()
        {
            List<MstDepartmentEntity> departments = MstDepartmentBs.GetDepartmentListAll(false);
            treeDepartment.DataSource = departments;
            treeDepartment.ExpandAll();
        }

        private void frmMaintainDepartmentQuery_Load(object sender, EventArgs e)
        {
            BindTreeDepartment();
        }

        protected override void Click_Confirm()
        {
            if (SelectedDepartment != null)
            {
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("请选择一个部门", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void treeDepartment_AfterFocusNode(object sender, DevExpress.XtraTreeList.NodeEventArgs e)
        {
            SelectedDepartment = MstDepartmentBs.GetMstDepartmentByID(e.Node.GetValue("DepartmentId").ToString());
        }

        private void treeDepartment_DoubleClick(object sender, EventArgs e)
        {
            if (SelectedDepartment != null)
            {
                this.DialogResult = DialogResult.OK;
            }
        }

    }
}
